package com.hzqy.service.system;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.system.SysProcessLogsDao;
import com.hzqy.service.core.GenericServiceBean;
import com.hzqy.web.vo.StatDataListenVo;
import com.hzqy.web.vo.SysProcessLogsVo;
import com.hzqy.web.vo.content.CmContentLedgerVo;


@Service
public class SysProcessLogsServiceBeen extends GenericServiceBean<SysProcessLogsVo, SysProcessLogsDao, Integer>{
	private static final long serialVersionUID = 1L;
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	@Resource
	private SysProcessLogsDao sysProcessLogsDao;
	
	@Override
	public SysProcessLogsDao getEntityDao() {
		// TODO Auto-generated method stub
		return sysProcessLogsDao;
	}
	/**
	 * 增加内容---批量入库和单条入库都利用此方法
	 * @param contentVo
	 * @return
	 */
	public int insertProcessLogs(SysProcessLogsVo sysProcessLogsVo ) {
		return sysProcessLogsDao.insertProcessLogs(sysProcessLogsVo);
	}
	public String selectProcessName(String f_pa_url){
		return sysProcessLogsDao.selectProcessName(f_pa_url);
	}
	public Map<String, Object> selectProcessLogsVoList(SysProcessLogsVo sysProcessLogsVo, int page, int rows) {
		Map<String,Object> map = new HashMap<String, Object>();
		int rowCount = sysProcessLogsDao.selectProcessLogsCount(sysProcessLogsVo);
		map.put("total", rowCount);
		if(rowCount > 0 && page > 0 && rows > 0) {
			map.put("f_spl_name", sysProcessLogsVo.getF_spl_name());
			map.put("f_spl_username",sysProcessLogsVo.getF_spl_username());
			map.put("f_spl_userid", sysProcessLogsVo.getF_spl_userid());
			map.put("beginDate", sysProcessLogsVo.getBeginDate());
			map.put("endDate", sysProcessLogsVo.getEndDate());
			map.put("firstResult", (page-1)*rows);
			map.put("maxResults", rows);
			List<SysProcessLogsVo> sysProcessLogsVoList=sysProcessLogsDao.selectProcessLogsVoList(map);
			map.put("rows", sysProcessLogsVoList);
		}else{
			map.put("rows", new ArrayList<SysProcessLogsVo>());
		}
		return map;
	}
	public Map<String, Object> selectContentLedgerList(CmContentLedgerVo cmContentLedgerVo, int curPage, int pageSize) {
		Map<String,Object> map = new HashMap<String, Object>();
		Integer rowCount = sysProcessLogsDao.selectContentLedgerListCount(cmContentLedgerVo);
		map.put("total", rowCount);
		if(rowCount > 0 && curPage > 0 && pageSize > 0) {
			map.put("firstResult", (curPage-1)*pageSize);
			map.put("maxResults", pageSize);
			map.put("f_ccl_contentName", cmContentLedgerVo.getF_ccl_contentName());
			map.put("f_ccl_user", cmContentLedgerVo.getF_ccl_user());
			map.put("f_ccl_ip", cmContentLedgerVo.getF_ccl_ip());
			map.put("f_ccl_type", cmContentLedgerVo.getF_ccl_type());
			List<StatDataListenVo> results = sysProcessLogsDao.selectContentLedgerList(map);
			map.put("rows", results);
		} else {
			map.put("rows", new ArrayList<StatDataListenVo>());
		}
		return map;
	}
}